package cn.itcast.flink.source;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.Arrays;

/**
 * @author lilulu
 */
public class StreamSourceCollectionDemo {
    public static void main(String[] args) throws Exception {
        // 1. 执行环境-env
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        // 2. 数据源-source
        //可变参数
//        DataStreamSource<String> source = env.fromElements("spark", "flink", "mapreduce", "hive");
        //集合对象
//        DataStreamSource<String> source1 = env.fromCollection(Arrays.asList("spark", "flink", "mapreduce", "hive"));
        //自动生成序列数字
        DataStreamSource<Long> source = env.fromSequence(1, 10);
        source.print();
        // 3. 数据转换-transformation
        // 4. 数据终端-sink
        // 5. 触发执行-execute
        env.execute("StreamSourceCollectionDemo");
    }
}